package top.infopub.mgr.cap.dao;

import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import top.infopub.generic.GenericDao;
import top.infopub.model.cap.FinancingApproval;
import top.infopub.model.cap.InformationSubmitApproval;
import top.infopub.model.cap.ReportMaterial;
import top.infopub.model.cap.SetupFinancial;
import top.infopub.model.flow.ProcessNode;
import top.infopub.model.mkt.BidPlan;

import java.util.List;
import java.util.Map;

/**
 * @Author Warking
 * @Date 2021/5/22 12:37
 * @Version 1.0 资料报审
 */
@Repository
public interface InformationSubmitApprovalDao extends GenericDao<BidPlan, String> {
    /*资料报审列表接口*/
    Page<InformationSubmitApproval> selectPage(InformationSubmitApproval informationSubmitApproval);
    /*资料报审详情跳转查询主阶段表的数据*/
    InformationSubmitApproval selectByKey(@Param("id") String id);
    /*查询有几条融资报审*/
    int sumByProCode(@Param("proCode")String proCode);
    /*查询融资数据 J是融资Name*/
    FinancingApproval financeByProCode(@Param("proCode")String proCode, @Param("name")String j);
    /*根据ID查询报审资料数据*/
    List<ReportMaterial> findByJinRoId(@Param("id")String id);
    /*根据processId流程ID查询并且存放审批意见*/
    List<ProcessNode> selectProcessNodeByProcessId(@Param("id") String processId);
    //资料报审详情金融机构下拉框数据
    List<Map<String, String>> queryFinancialDetail(@Param("proCode")String proCode);
    /*资料报审金融机构下拉框选择事件接口*/
    SetupFinancial querySetupFinancialDetail(@Param("id")String id,@Param("proCode")String proCode);
    /*根据融资 proCode和name 查询是否保存了--存在这条记录*/
    int findByNameAndProCode(@Param("name")String name,@Param("proCode") String proCode);
    /*保存融资表的数据*/
    void addFinancingApproval(FinancingApproval financingApproval);
    /*保存金融数据*/
    void addSetupFinancial(SetupFinancial setupFinancial);
    /*保存报审数据*/
    void addReportMaterial(ReportMaterial reportMaterial);
    /*根据金融ID删除报审资料*/
    void deleteReportById(@Param("capSetupFinancialId")String jinRoId);
    /*删除金融数据*/
    void deleteSetupFinancialById(@Param("id")String jinRoId);
    /*删除之前的融资报审数据*/
    void deleteByFinanceId(@Param("id")String id);
    /** 根据流程走向新增资料报审信息 */
    void insertByProcess(InformationSubmitApproval isa);
    /*查询融资报审表数据*/
    FinancingApproval financeByProCodeMaxName(@Param("proCode")String proCode);
    /*根据融资ID取中间表取数据*/
    List<Map<String, String>> findByMiddleList(@Param("id")String id);
    /*根据金融ID 查询金融数据*/
    SetupFinancial findByJinRoSGUID(@Param("id")String setupFinancialId);
    /*把数据保存到融资和金融的中间表*/
    void insertByMiddleWrite(@Param("financingApprovalId")String financingApprovalId,@Param("setupFinancialId") String setupFinancialId);
    /*最后再删除之前中间表关联的融资ID和金融ID*/
    void deleteMiddleByRoZhiId(@Param("financingApprovalId")String id);
}
